package com.example.hospitalManage.controller.admin.api;

/**
 * @param null:
 * @return null
 * @author GCT
 * @description TODO
 * @date 2023/1/2 21:57
 */
//import com.example.Msg.Msg;
import com.example.hospitalManage.utils.Response;
import com.example.hospitalManage.utils.ResponseResult;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//@ControllerAdvice可以实现全局异常处理，可以简单理解为增强了的controller
@ControllerAdvice
public class MyExceptionHandler {

    //捕获AuthorizationException的异常
    @ExceptionHandler(value = AuthorizationException.class)
    @ResponseBody
    public ResponseResult<Object> handleException(AuthorizationException e) {
//        Msg msg=Msg.denyAccess("权限不足呀！！！！！");
        ResponseResult<Object> failResp = Response.createFailResp("权限不足！！！！！");
        return failResp;
    }

}
